home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C++ / Frameworks / Sprocket Framework DR2 / Sprocket Starter / SprocketStarter Code / WASTE.h < prev   
Encoding:
C/C++ Source or Header  |  1996-01-13  |  32.5 KB  |  760 lines  |  [TEXT/CWIE]

  1. /*
  2.  *    WASTE.h
  3.  *
  4.  *    C/C++ interface to the WASTE text engine
  5.  *
  6.  *    version 1.2a5 (January 1996)
  7.  *
  8.  *    Copyright (c) 1993-1996 Marco Piovanelli
  9.  *    All Rights Reserved
  10.  * 
  11.  */
  12.  
  13. #ifndef _WASTE_
  14. #define _WASTE_
  15.  
  16. #ifndef __CONDITIONALMACROS__
  17. #include <ConditionalMacros.h>
  18. #endif
  19.  
  20. #ifndef __TYPES__
  21. #include <Types.h>
  22. #endif
  23.  
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27.  
  28. #ifndef __QUICKDRAWTEXT__
  29. #include <QuickdrawText.h>
  30. #endif
  31.  
  32. #ifndef __QUICKDRAW__
  33. #include <Quickdraw.h>
  34. #endif
  35.  
  36. #ifndef __SCRIPT__
  37. #include <Script.h>
  38. #endif
  39.  
  40. #ifndef __TEXTUTILS__
  41. #include <TextUtils.h>
  42. #endif
  43.  
  44. #ifndef __TEXTEDIT__
  45. #include <TextEdit.h>
  46. #endif
  47.  
  48. #ifndef __DRAG__
  49. #include <Drag.h>
  50. #endif
  51.  
  52. #ifndef __LONGCOORDINATES__
  53. #ifndef _LongCoords_
  54. #include "LongCoords.h"
  55. #endif
  56. #endif
  57.  
  58. // if we're using a pre-2.1 version of the Universal Headers, define EventModifiers
  59. #ifndef UNIVERSAL_INTERFACES_VERSION
  60. typedef unsigned short EventModifiers;
  61. #endif
  62.  
  63. #if defined(powerc) || defined (__powerc)
  64. #pragma options align=mac68k
  65. #endif
  66.  
  67. //    The macro WASTE_VERSION expands to the current version of WASTE,
  68. //    expressed in standard NumVersion format (see Types.h)
  69. //    The macro WASTE11 is obsolete but still supported for backward
  70. //    compatibility
  71.  
  72. #define WASTE_VERSION    0x01204005
  73. #define WASTE11
  74.  
  75. /*    result codes */
  76.  
  77. enum {
  78.     weCantUndoErr            =    -10015,    /* undo buffer is clear (= errAECantUndo) */
  79.     weEmptySelectionErr        =    -10013,    /* selection range is empty (= errAENoUserSelection) */
  80.     weNotHandledErr            =    -1708,    /* please use default behavior (= errAEEventNotHandled) */
  81.     weUnknownObjectTypeErr    =    -9478,    /* specified object type is not registered */
  82.     weObjectNotFoundErr        =    -9477,    /* no object found at specified offset */
  83.     weReadOnlyErr            =    -9476,    /* instance is read-only */
  84.     weUndefinedSelectorErr    =    -50        /* unknown selector (= paramErr) */
  85. };
  86.  
  87. /*    alignment styles */
  88.  
  89. enum {
  90.     weFlushLeft         =    -2,        /* flush left */
  91.     weFlushRight        =    -1,        /* flush right */
  92.     weFlushDefault        =     0,        /* flush according to system direction */
  93.     weCenter            =     1,        /* centered */
  94.     weJustify            =     2        /* fully justified */
  95. };
  96.  
  97. /*    values for the mode parameter in WESetStyle and WEContinuousStyle */
  98.  
  99. enum {
  100.     weDoFont                =    0x0001,
  101.     weDoFace                =    0x0002,
  102.     weDoSize                =    0x0004,
  103.     weDoColor                =    0x0008,
  104.     weDoAll                    =    weDoFont + weDoFace + weDoSize + weDoColor,
  105.     weDoAddSize                =    0x0010,
  106.     weDoToggleFace            =    0x0020,
  107.     weDoReplaceFace            =    0x0040,
  108.     weDoPreserveScript        =    0x0080,
  109.     weDoExtractSubscript    =    0x0100,
  110.     weDoFaceMask            =    0x0200
  111. };
  112.  
  113. /*    values for the edge parameter in WEGetOffset etc. */
  114.  
  115. enum {
  116.     kLeadingEdge = -1,        /* point is on the leading edge of a glyph */
  117.     kTrailingEdge = 0,        /* point is on the trailing edge of a glyph */
  118.     kObjectEdge = 2            /* point is in the middle of an embedded object */
  119. };
  120.  
  121. /*    values for WEFeatureFlag feature parameter */
  122.  
  123. enum {
  124.     weFAutoScroll        =    0,        /* automatically scroll the selection range into view */
  125.     weFOutlineHilite    =    2,        /* frame selection when deactivated */
  126.     weFReadOnly            =    5,        /* disallow modifications */
  127.     weFUndo                =    6,        /* support WEUndo() */
  128.     weFIntCutAndPaste    =    7,        /* use intelligent cut-and-paste rules */
  129.     weFDragAndDrop        =    8,        /* support drag-and-drop text editing */
  130.     weFInhibitRecal        =    9,        /* don't recalculate line starts and don't redraw text */
  131.     weFUseTempMem        =    10,        /* use temporary memory for main data structures */
  132.     weFDrawOffscreen    =    11,        /* draw text offscreen for smoother visual results */
  133.     weFInhibitRedraw    =    12,        /* don't redraw text */
  134.     weFMonoStyled        =    13,        /* disallow style changes */
  135.     weFInhibitColor        =    31        /* draw in black & white only */
  136. };
  137.  
  138. /*    values for WENew flags parameter */
  139.  
  140. enum {
  141.     weDoAutoScroll        =    1L << weFAutoScroll,
  142.     weDoOutlineHilite    =    1L << weFOutlineHilite,
  143.     weDoReadOnly        =    1L << weFReadOnly,
  144.     weDoUndo            =    1L << weFUndo,
  145.     weDoIntCutAndPaste    =    1L << weFIntCutAndPaste,
  146.     weDoDragAndDrop        =    1L << weFDragAndDrop,
  147.     weDoInhibitRecal    =    1L << weFInhibitRecal,
  148.     weDoUseTempMem        =    1L << weFUseTempMem,
  149.     weDoDrawOffscreen    =    1L << weFDrawOffscreen,
  150.     weDoInhibitRedraw    =    1L << weFInhibitRedraw,
  151.     weDoMonoStyled        =    1L << weFMonoStyled,
  152.     weDoInhibitColor    =    1L << weFInhibitColor
  153. };
  154.  
  155. /*    values for WEFeatureFlag action parameter */
  156.  
  157. enum {
  158.     weBitToggle = -2,    /* toggles the specified feature */
  159.     weBitTest,            /* returns the current setting of the specified feature */
  160.     weBitClear,            /* disables the specified feature */
  161.     weBitSet            /* enables the specified feature */
  162. };
  163.  
  164. /*    selectors for WEGetInfo and WESetInfo */
  165.  
  166. enum {
  167.     weCharByteHook        =    'cbyt', /* CharByte hook */
  168.     weCharToPixelHook    =    'c2p ',    /* CharToPixel hook */
  169.     weCharTypeHook        =    'ctyp', /* CharType hook */
  170.     weClickLoop            =    'clik',    /* click loop callback */
  171.     weCurrentDrag        =    'drag',    /* drag currently being tracked from WEClick() */
  172.     weDrawTextHook        =    'draw', /* text drawing hook */
  173.     weLineBreakHook        =    'lbrk',    /* line breaking hook */
  174.     wePixelToCharHook    =    'p2c ', /* PixelToChar hook */
  175.     wePort                =    'port',    /* graphics port */
  176.     weRefCon            =    'refc',    /* reference constant for use by application */
  177.     weScrollProc        =    'scrl',    /* auto-scroll callback */
  178.     weText                =    'text',    /* text handle */
  179.     weTranslateDragHook =    'xdrg', /* drag translation callback */
  180.     weTSMDocumentID        =    'tsmd',    /* Text Services Manager document ID */
  181.     weTSMPreUpdate        =    'pre ',    /* Text Services Manager pre-update callback */
  182.     weTSMPostUpdate        =    'post',    /* Text Services Manager post-update callback */
  183.     weURLHint            =    'urlh',    /* URL hint string for Internet Config */
  184.     weWordBreakHook        =    'wbrk'    /* word breaking hook */
  185. };
  186.  
  187. /*    values for WEInstallObjectHandler handlerSelector parameter */
  188.  
  189. enum {
  190.     weNewHandler        =    'new ',        /* new handler */
  191.     weDisposeHandler    =    'free',        /* dispose handler */
  192.     weDrawHandler        =    'draw',        /* draw handler */
  193.     weClickHandler        =    'clik',        /* click handler */
  194.     weStreamHandler        =    'strm'        /* stream handler */
  195. };
  196.  
  197. /*    action kinds */
  198.  
  199. enum {
  200.     weAKNone            =    0,        /* null action */
  201.     weAKUnspecified        =    1,        /* action of unspecified nature */
  202.     weAKTyping            =    2,        /* some text has been typed in */
  203.     weAKCut                =    3,        /* the selection range has been cut */
  204.     weAKPaste            =    4,        /* something has been pasted */
  205.     weAKClear            =    5,        /* the selection range has been deleted */
  206.     weAKDrag            =    6,        /* drag and drop operation */
  207.     weAKSetStyle        =    7        /* some style has been applied to a text range */
  208. };
  209.  
  210. /*    destination kinds for stream handler */
  211.  
  212. enum {
  213.     weToScrap            =    0,
  214.     weToDrag            =    1,
  215.     weToSoup            =    2
  216. };
  217.  
  218. typedef struct OpaqueWEReference *WEReference;
  219. typedef struct OpaqueWEObjectReference *WEObjectReference;
  220. typedef Handle WESoupHandle;
  221. typedef short WEActionKind;
  222. typedef char WEAlignment;
  223. typedef unsigned short WEStyleMode;
  224. typedef FourCharCode WESelector;
  225. typedef WEReference WEHandle;    /* obsolete, kept for backward compatibility */
  226.  
  227. typedef struct WERunInfo {
  228.     long                 runStart;    /* byte offset to first character of style run */
  229.     long                 runEnd;        /* byte offset past last character of style run */
  230.     short                 runHeight;    /* line height (ascent + descent + leading) */
  231.     short                 runAscent;    /* font ascent */
  232.     TextStyle             runStyle;    /* text attributes */
  233.     WEObjectReference    runObject;    /* either NULL or reference to embedded object */
  234. } WERunInfo;
  235.  
  236.  
  237. /*    callback prototypes */
  238.  
  239. typedef pascal Boolean (*WEClickLoopProcPtr)(WEReference we);
  240. typedef pascal void (*WEScrollProcPtr)(WEReference we);
  241. typedef pascal void (*WETSMPreUpdateProcPtr)(WEReference we);
  242. typedef pascal void (*WETSMPostUpdateProcPtr)(WEReference we,
  243.         long fixLength, long inputAreaStart, long inputAreaEnd,
  244.         long pinRangeStart, long pinRangeEnd);
  245. typedef pascal OSErr (*WETranslateDragProcPtr)(DragReference theDrag,
  246.         ItemReference theItem, FlavorType requestedType, Handle putDataHere);
  247. typedef pascal void (*WEDrawTextProcPtr)(Ptr pText, long textLength, Fixed slop,
  248.         JustStyleCode styleRunPosition, WEReference we);
  249. typedef pascal long (*WEPixelToCharProcPtr)(Ptr pText, long textLength, Fixed slop,
  250.         Fixed *pixelWidth, char *edge, JustStyleCode styleRunPosition, Fixed hPos, WEReference we);
  251. typedef pascal short (*WECharToPixelProcPtr)(Ptr pText, long textLength, Fixed slop,
  252.         long offset, short direction, JustStyleCode styleRunPosition, long hPos, WEReference we);
  253. typedef pascal StyledLineBreakCode (*WELineBreakProcPtr)(Ptr pText, long textLength,
  254.         long textStart, long textEnd, Fixed *textWidth, long *textOffset, WEReference we);
  255. typedef pascal void (*WEWordBreakProcPtr)(Ptr pText, short textLength, short offset,
  256.         char edge, OffsetTable breakOffsets, ScriptCode script, WEReference we);
  257. typedef pascal short (*WECharByteProcPtr)(Ptr pText, short textOffset, ScriptCode script,
  258.         WEReference we);
  259. typedef pascal short (*WECharTypeProcPtr)(Ptr pText, short textOffset, ScriptCode script, WEReference we);
  260. typedef pascal OSErr (*WENewObjectProcPtr)(Point *defaultObjectSize,
  261.         WEObjectReference obj);
  262. typedef pascal OSErr (*WEDisposeObjectProcPtr)(WEObjectReference obj);
  263. typedef pascal OSErr (*WEDrawObjectProcPtr)(const Rect *destRect,
  264.         WEObjectReference obj);
  265. typedef pascal Boolean (*WEClickObjectProcPtr)(Point hitPt, EventModifiers modifiers, unsigned long clickTime,
  266.         WEObjectReference obj);
  267. typedef pascal OSErr (*WEStreamObjectProcPtr)(short destKind, FlavorType *theType,
  268.         Handle putDataHere, WEObjectReference obj);
  269.  
  270.  
  271. /*    UPP proc info */
  272.  
  273. enum {
  274.     uppWEClickLoopProcInfo = kPascalStackBased
  275.         | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  276.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEReference /*we*/)))
  277. };
  278. enum {
  279.     uppWEScrollProcInfo = kPascalStackBased
  280.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEReference /*we*/)))
  281. };
  282. enum {
  283.     uppWETSMPreUpdateProcInfo = kPascalStackBased
  284.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEReference /*we*/)))
  285. };
  286. enum {
  287.     uppWETSMPostUpdateProcInfo = kPascalStackBased
  288.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEReference /*we*/)))
  289.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*fixLength*/)))
  290.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(long /*inputAreaStart*/)))
  291.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(long /*inputAreaEnd*/)))
  292.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(long /*pinRangeStart*/)))
  293.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(long /*pinRangeEnd*/)))
  294. };
  295. enum {
  296.     uppWETranslateDragProcInfo = kPascalStackBased
  297.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  298.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(DragReference /*theDrag*/)))
  299.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(ItemReference /*theItem*/)))
  300.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(FlavorType /*requestedType*/)))
  301.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(Handle /*putDataHere*/)))
  302. };
  303. enum {
  304.     uppWEDrawTextProcInfo = kPascalStackBased
  305.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  306.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*textLength*/)))
  307.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(Fixed /*slop*/)))
  308.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(JustStyleCode /*styleRunPosition*/)))
  309.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(WEReference /*we*/)))
  310. };
  311. enum {
  312.     uppWEPixelToCharProcInfo = kPascalStackBased
  313.         | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  314.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  315.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*textLength*/)))
  316.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(Fixed /*slop*/)))
  317.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(Fixed * /*pixelWidth*/)))
  318.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(char * /*edge*/)))
  319.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(JustStyleCode /*styleRunPosition*/)))
  320.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(Fixed /*hPos*/)))
  321.         | STACK_ROUTINE_PARAMETER(8,SIZE_CODE(sizeof(WEReference /*we*/)))
  322. };
  323. enum {
  324.     uppWECharToPixelProcInfo = kPascalStackBased
  325.         | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  326.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  327.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*textLength*/)))
  328.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(Fixed /*slop*/)))
  329.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(long /*offset*/)))
  330.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(short /*direction*/)))
  331.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(JustStyleCode /*styleRunPosition*/)))
  332.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(long /*hPos*/)))
  333.         | STACK_ROUTINE_PARAMETER(8,SIZE_CODE(sizeof(WEReference /*we*/)))
  334. };
  335. enum {
  336.     uppWELineBreakProcInfo = kPascalStackBased
  337.         | RESULT_SIZE(SIZE_CODE(sizeof(StyledLineBreakCode )))
  338.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  339.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*textLength*/)))
  340.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(long /*textStart*/)))
  341.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(long /*textEnd*/)))
  342.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(Fixed * /*textWidth*/)))
  343.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(long * /*textOffset*/)))
  344.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(WEReference /*we*/)))
  345. };
  346. enum {
  347.     uppWEWordBreakProcInfo = kPascalStackBased
  348.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  349.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(short /*textLength*/)))
  350.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(short /*offset*/)))
  351.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(char /*edge*/)))
  352.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(OffsetTable * /*breakOffsets*/)))
  353.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(ScriptCode /*script*/)))
  354.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(WEReference /*we*/)))
  355. };
  356. enum {
  357.     uppWECharByteProcInfo = kPascalStackBased
  358.         | RESULT_SIZE(SIZE_CODE(sizeof(short )))
  359.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  360.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(short /*textOffset*/)))
  361.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(ScriptCode /*script*/)))
  362.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(WEReference /*we*/)))
  363. };
  364. enum {
  365.     uppWECharTypeProcInfo = kPascalStackBased
  366.         | RESULT_SIZE(SIZE_CODE(sizeof(short )))
  367.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  368.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(short /*textOffset*/)))
  369.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(ScriptCode /*script*/)))
  370.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(WEReference /*we*/)))
  371. };
  372.  
  373.  
  374. enum {
  375.     uppWENewObjectProcInfo = kPascalStackBased
  376.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  377.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Point * /*defaultObjectSize*/)))
  378.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(WEObjectReference /*obj*/)))
  379. };
  380. enum {
  381.     uppWEDisposeObjectProcInfo = kPascalStackBased
  382.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  383.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEObjectReference /*obj*/)))
  384. };
  385. enum {
  386.     uppWEDrawObjectProcInfo = kPascalStackBased
  387.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  388.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(const Rect * /*destRect*/)))
  389.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(WEObjectReference /*obj*/)))
  390. };
  391. enum {
  392.     uppWEClickObjectProcInfo = kPascalStackBased
  393.         | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  394.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Point /*hitPt*/)))
  395.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(EventModifiers /*modifiers*/)))
  396.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(unsigned long /*clickTime*/)))
  397.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(WEObjectReference /*obj*/)))
  398. };
  399. enum {
  400.     uppWEStreamObjectProcInfo = kPascalStackBased
  401.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  402.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short /*destKind*/)))
  403.         | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(FlavorType * /*theType*/)))
  404.         | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Handle /*putDataHere*/)))
  405.         | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(WEObjectReference /*obj*/)))
  406. };
  407.  
  408.  
  409. /*    UPPs, New≈Proc macros & Call≈Proc macros */
  410.  
  411. /*
  412.     NOTE:
  413.     For compatibility with the Pascal version, Call≈Proc macros take the form:
  414.  
  415.         CallFooProc(..., userRoutine)
  416.  
  417.     instead of:
  418.  
  419.         CallFooProc(userRoutine, ...)
  420.  
  421. */
  422.  
  423. #if GENERATINGCFM
  424.  
  425. typedef UniversalProcPtr WEClickLoopUPP;
  426. typedef UniversalProcPtr WEScrollUPP;
  427. typedef UniversalProcPtr WETSMPreUpdateUPP;
  428. typedef UniversalProcPtr WETSMPostUpdateUPP;
  429. typedef UniversalProcPtr WETranslateDragUPP;
  430. typedef UniversalProcPtr WEDrawTextUPP;
  431. typedef UniversalProcPtr WEPixelToCharUPP;
  432. typedef UniversalProcPtr WECharToPixelUPP;
  433. typedef UniversalProcPtr WELineBreakUPP;
  434. typedef UniversalProcPtr WEWordBreakUPP;
  435. typedef UniversalProcPtr WECharByteUPP;
  436. typedef UniversalProcPtr WECharTypeUPP;
  437. typedef UniversalProcPtr WENewObjectUPP;
  438. typedef UniversalProcPtr WEDisposeObjectUPP;
  439. typedef UniversalProcPtr WEDrawObjectUPP;
  440. typedef UniversalProcPtr WEClickObjectUPP;
  441. typedef UniversalProcPtr WEStreamObjectUPP;
  442.  
  443. #define NewWEClickLoopProc(userRoutine) \
  444.     (WEClickLoopUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEClickLoopProcInfo, GetCurrentArchitecture())
  445. #define NewWEScrollProc(userRoutine) \
  446.     (WEScrollUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEScrollProcInfo, GetCurrentArchitecture())
  447. #define NewWETSMPreUpdateProc(userRoutine) \
  448.     (WETSMPreUpdateUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWETSMPreUpdateProcInfo, GetCurrentArchitecture())
  449. #define NewWETSMPostUpdateProc(userRoutine) \
  450.     (WETSMPostUpdateUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWETSMPostUpdateProcInfo, GetCurrentArchitecture())
  451. #define NewWETranslateDragProc(userRoutine) \
  452.     (WETranslateDragUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWETranslateDragProcInfo, GetCurrentArchitecture())
  453. #define NewWEDrawTextProc(userRoutine) \
  454.     (WEDrawTextUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEDrawTextProcInfo, GetCurrentArchitecture())
  455. #define NewWEPixelToCharProc(userRoutine) \
  456.     (WEPixelToCharUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEPixelToCharProcInfo, GetCurrentArchitecture())
  457. #define NewWECharToPixelProc(userRoutine) \
  458.     (WECharToPixelUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWECharToPixelProcInfo, GetCurrentArchitecture())
  459. #define NewWELineBreakProc(userRoutine) \
  460.     (WELineBreakUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWELineBreakProcInfo, GetCurrentArchitecture())
  461. #define NewWEWordBreakProc(userRoutine) \
  462.     (WEWordBreakUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEWordBreakProcInfo, GetCurrentArchitecture())
  463. #define NewWECharByteProc(userRoutine) \
  464.     (WECharByteUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWECharByteProcInfo, GetCurrentArchitecture())
  465. #define NewWECharTypeProc(userRoutine) \
  466.     (WECharTypeUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWECharTypeProcInfo, GetCurrentArchitecture())
  467. #define NewWENewObjectProc(userRoutine) \
  468.     (WENewObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWENewObjectProcInfo, GetCurrentArchitecture())
  469. #define NewWEDisposeObjectProc(userRoutine) \
  470.     (WEDisposeObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEDisposeObjectProcInfo, GetCurrentArchitecture())
  471. #define NewWEDrawObjectProc(userRoutine) \
  472.     (WEDrawObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEDrawObjectProcInfo, GetCurrentArchitecture())
  473. #define NewWEClickObjectProc(userRoutine) \
  474.     (WEClickObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEClickObjectProcInfo, GetCurrentArchitecture())
  475. #define NewWEStreamObjectProc(userRoutine) \
  476.     (WEStreamObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEStreamObjectProcInfo, GetCurrentArchitecture())
  477.  
  478. #define CallWEClickLoopProc(we, userRoutine) \
  479.     CallUniversalProc((userRoutine), uppWEClickLoopProcInfo, (we))
  480. #define CallWEScrollProc(we, userRoutine) \
  481.     CallUniversalProc((userRoutine), uppWEScrollProcInfo, (we))
  482. #define CallWETSMPreUpdateProc(we, userRoutine) \
  483.     CallUniversalProc((userRoutine), uppWETSMPreUpdateProcInfo, (we))
  484. #define CallWETSMPostUpdateProc(we, fixLength, inputAreaStart, inputAreaEnd, pinRangeStart, pinRangeEnd, userRoutine) \
  485.     CallUniversalProc((userRoutine), uppWETSMPostUpdateProcInfo, (we), (fixLength), (inputAreaStart), (inputAreaEnd), (pinRangeStart), (pinRangeEnd))
  486. #define CallWETranslateDragProc(theDrag, theItem, requestedType, putDataHere, userRoutine) \
  487.     CallUniversalProc((userRoutine), uppWETranslateDragProcInfo, (theDrag), (theItem), (requestedType), (putDataHere))
  488. #define CallWEDrawTextProc(pText, textLength, slop, styleRunPosition, we, userRoutine) \
  489.     CallUniversalProc((userRoutine), uppWEDrawTextProcInfo, (pText), (textLength), (slop), (styleRunPosition), (we))
  490. #define CallWEPixelToCharProc(pText, textLength, slop, pixelWidth, edge, styleRunPosition, hPos, we, userRoutine) \
  491.     CallUniversalProc((userRoutine), uppWEPixelToCharProcInfo, (pText), (textLength), (slop), (pixelWidth), (edge), (styleRunPosition), (hPos), (we))
  492. #define CallWECharToPixelProc(pText, textLength, slop, offset, direction, styleRunPosition, hPos, we, userRoutine) \
  493.     CallUniversalProc((userRoutine), uppWECharToPixelProcInfo, (pText), (textLength), (slop), (offset), (direction), (styleRunPosition), (hPos), (we))
  494. #define CallWELineBreakProc(pText, textLength, textStart, textEnd, textWidth, textOffset, we, userRoutine) \
  495.     CallUniversalProc((userRoutine), uppWELineBreakProcInfo, (pText), (textLength), (textStart), (textEnd), (textWidth), (textOffset), (we))
  496. #define CallWEWordBreakProc(pText, textLength, offset, edge, breakOffsets, script, we, userRoutine) \
  497.     CallUniversalProc((userRoutine), uppWEWordBreakProcInfo, (pText), (textLength), (offset), (edge), (breakOffsets), (script), (we))
  498. #define CallWECharByteProc(pText, textOffset, script, we, userRoutine) \
  499.     CallUniversalProc((userRoutine), uppWECharByteProcInfo, (pText), (textOffset), (script), (we))
  500. #define CallWECharTypeProc(pText, textOffset, script, we, userRoutine) \
  501.     CallUniversalProc((userRoutine), uppWECharTypeProcInfo, (pText), (textOffset), (script), (we))
  502. #define CallWENewObjectProc(defaultObjectSize, obj, userRoutine) \
  503.     CallUniversalProc((userRoutine), uppWENewObjectProcInfo, (defaultObjectSize), (obj))
  504. #define CallWEDisposeObjectProc(obj, userRoutine) \
  505.     CallUniversalProc((userRoutine), uppWEDisposeObjectProcInfo, (obj))
  506. #define CallWEDrawObjectProc(destRect, obj, userRoutine) \
  507.     CallUniversalProc((userRoutine), uppWEDrawObjectProcInfo, (destRect), (obj))
  508. #define CallWEClickObjectProc(hitPt, modifiers, clickTime, obj, userRoutine) \
  509.     CallUniversalProc((userRoutine), uppWEClickObjectProcInfo, (hitPt), (modifiers), (clickTime), (obj))
  510. #define CallWEStreamObjectProc(destKind, theType, putDataHere, obj, userRoutine) \
  511.     CallUniversalProc((userRoutine), uppWEStreamObjectProcInfo, (destKind), (theType), (putDataHere), (obj))
  512.  
  513. #else
  514.  
  515. typedef WEClickLoopProcPtr WEClickLoopUPP;
  516. typedef WEScrollProcPtr WEScrollUPP;
  517. typedef WETSMPreUpdateProcPtr WETSMPreUpdateUPP;
  518. typedef WETSMPostUpdateProcPtr WETSMPostUpdateUPP;
  519. typedef WETranslateDragProcPtr WETranslateDragUPP;
  520. typedef WEDrawTextProcPtr WEDrawTextUPP;
  521. typedef WEPixelToCharProcPtr WEPixelToCharUPP;
  522. typedef WECharToPixelProcPtr WECharToPixelUPP;
  523. typedef WELineBreakProcPtr WELineBreakUPP;
  524. typedef WEWordBreakProcPtr WEWordBreakUPP;
  525. typedef WECharByteProcPtr WECharByteUPP;
  526. typedef WECharTypeProcPtr WECharTypeUPP;
  527. typedef WENewObjectProcPtr WENewObjectUPP;
  528. typedef WEDisposeObjectProcPtr WEDisposeObjectUPP;
  529. typedef WEDrawObjectProcPtr WEDrawObjectUPP;
  530. typedef WEClickObjectProcPtr WEClickObjectUPP;
  531. typedef WEStreamObjectProcPtr WEStreamObjectUPP;
  532.  
  533. #define NewWEClickLoopProc(userRoutine) ((WEClickLoopUPP) (userRoutine))
  534. #define NewWEScrollProc(userRoutine) ((WEScrollUPP) (userRoutine))
  535. #define NewWETSMPreUpdateProc(userRoutine) ((WETSMPreUpdateUPP) (userRoutine))
  536. #define NewWETSMPostUpdateProc(userRoutine) ((WETSMPostUpdateUPP) (userRoutine))
  537. #define NewWETranslateDragProc(userRoutine) ((WETranslateDragUPP) (userRoutine))
  538. #define NewWEDrawTextProc(userRoutine) ((WEDrawTextUPP) (userRoutine))
  539. #define NewWEPixelToCharProc(userRoutine) ((WEPixelToCharUPP) (userRoutine))
  540. #define NewWECharToPixelProc(userRoutine) ((WECharToPixelUPP) (userRoutine))
  541. #define NewWELineBreakProc(userRoutine) ((WELineBreakUPP) (userRoutine))
  542. #define NewWEWordBreakProc(userRoutine) ((WEWordBreakUPP) (userRoutine))
  543. #define NewWECharByteProc(userRoutine) ((WECharByteUPP) (userRoutine))
  544. #define NewWECharTypeProc(userRoutine) ((WECharTypeUPP) (userRoutine))
  545. #define NewWENewObjectProc(userRoutine) ((WENewObjectUPP) (userRoutine))
  546. #define NewWEDisposeObjectProc(userRoutine) ((WEDisposeObjectUPP) (userRoutine))
  547. #define NewWEDrawObjectProc(userRoutine) ((WEDrawObjectUPP) (userRoutine))
  548. #define NewWEClickObjectProc(userRoutine) ((WEClickObjectUPP) (userRoutine))
  549. #define NewWEStreamObjectProc(userRoutine) ((WEStreamObjectUPP) (userRoutine))
  550.  
  551. #define CallWEClickLoopProc(we, userRoutine) \
  552.     (*(userRoutine))((we))
  553. #define CallWEScrollProc(we, userRoutine) \
  554.     (*(userRoutine))((we))
  555. #define CallWETSMPreUpdateProc(we, userRoutine) \
  556.     (*(userRoutine))((we))
  557. #define CallWETSMPostUpdateProc(we, fixLength, inputAreaStart, inputAreaEnd, pinRangeStart, pinRangeEnd, userRoutine) \
  558.     (*(userRoutine))((we), (fixLength), (inputAreaStart), (inputAreaEnd), (pinRangeStart), (pinRangeEnd))
  559. #define CallWETranslateDragProc(theDrag, theItem, requestedType, putDataHere, userRoutine) \
  560.     (*(userRoutine))((theDrag), (theItem), (requestedType), (putDataHere))
  561. #define CallWEDrawTextProc(pText, textLength, slop, styleRunPosition, we, userRoutine) \
  562.     (*(userRoutine))((pText), (textLength), (slop), (styleRunPosition), (we))
  563. #define CallWEPixelToCharProc(pText, textLength, slop, pixelWidth, edge, styleRunPosition, hPos, we, userRoutine) \
  564.     (*(userRoutine))((pText), (textLength), (slop), (pixelWidth), (edge), (styleRunPosition), (hPos), (we))
  565. #define CallWECharToPixelProc(pText, textLength, slop, offset, direction, styleRunPosition, hPos, we, userRoutine) \
  566.     (*(userRoutine))((pText), (textLength), (slop), (offset), (direction), (styleRunPosition), (hPos), (we))
  567. #define CallWELineBreakProc(pText, textLength, textStart, textEnd, textWidth, textOffset, we, userRoutine) \
  568.     (*(userRoutine))((pText), (textLength), (textStart), (textEnd), (textWidth), (textOffset), (we))
  569. #define CallWEWordBreakProc(pText, textLength, offset, edge, breakOffsets, script, we, userRoutine) \
  570.     (*(userRoutine))((pText), (textLength), (offset), (edge), (breakOffsets), (script), (we))
  571. #define CallWECharByteProc(pText, textOffset, script, we, userRoutine) \
  572.     (*(userRoutine))((pText), (textOffset), (script), (we))
  573. #define CallWECharTypeProc(pText, textOffset, script, we, userRoutine) \
  574.     (*(userRoutine))((pText), (textOffset), (script), (we))
  575. #define CallWENewObjectProc(defaultObjectSize, obj, userRoutine) \
  576.     (*(userRoutine))((defaultObjectSize), (obj))
  577. #define CallWEDisposeObjectProc(obj, userRoutine) \
  578.     (*(userRoutine))((obj))
  579. #define CallWEDrawObjectProc(destRect, obj, userRoutine) \
  580.     (*(userRoutine))((destRect), (obj))
  581. #define CallWEClickObjectProc(hitPt, modifiers, clickTime, obj, userRoutine) \
  582.     (*(userRoutine))((hitPt), (modifiers), (clickTime), (obj))
  583. #define CallWEStreamObjectProc(destKind, theType, putDataHere, obj, userRoutine) \
  584.     (*(userRoutine))((destKind), (theType), (putDataHere), (obj))
  585.  
  586. #endif
  587.  
  588.  
  589. /*    WASTE public calls */
  590.  
  591. #ifdef __cplusplus
  592. extern "C" {
  593. #endif
  594.  
  595. /*    creation and destruction */
  596.  
  597. pascal OSErr WENew(const LongRect *destRect, const LongRect *viewRect, unsigned long flags, WEReference *we);
  598. pascal void WEDispose(WEReference we);
  599.  
  600. /*    getting variables */
  601.  
  602. pascal Handle WEGetText(WEReference we);
  603. pascal short WEGetChar(long offset, WEReference we);
  604. pascal long WEGetTextLength(WEReference we);
  605. pascal long WECountLines(WEReference we);
  606. pascal long WEGetHeight(long startLine, long endLine, WEReference we);
  607. pascal void WEGetSelection(long *selStart, long *selEnd, WEReference we);
  608. pascal void WEGetDestRect(LongRect *destRect, WEReference we);
  609. pascal void WEGetViewRect(LongRect *viewRect, WEReference we);
  610. pascal Boolean WEIsActive(WEReference we);
  611. pascal long WEOffsetToLine (long offset, WEReference we);
  612. pascal void WEGetLineRange(long lineNo, long *lineStart, long *lineEnd, WEReference we);
  613.  
  614. /*    setting variables */
  615.  
  616. pascal void WESetSelection(long selStart, long selEnd, WEReference we);
  617. pascal void WESetDestRect(const LongRect *destRect, WEReference we);
  618. pascal void WESetViewRect(const LongRect *viewRect, WEReference we);
  619.  
  620. /*    accessing style run information */
  621.  
  622. pascal Boolean WEContinuousStyle(WEStyleMode *mode, TextStyle *ts, WEReference we);
  623. pascal void WEGetRunInfo(long offset, WERunInfo *runInfo, WEReference we);
  624.  
  625. /*    converting byte offsets to screen position and vice versa */
  626.  
  627. pascal long WEGetOffset(const LongPt *thePoint, char *edge, WEReference we);
  628. pascal void WEGetPoint(long offset, LongPt *thePoint, short *lineHeight, WEReference we);
  629.  
  630. /*    finding words and lines */
  631.  
  632. pascal void WEFindWord(long offset, char edge, long *wordStart, long *wordEnd, WEReference we);
  633. pascal void WEFindLine(long offset, char edge, long *lineStart, long *lineEnd, WEReference we);
  634.  
  635. /*    making a copy of a text range */
  636.  
  637. pascal OSErr WECopyRange(long rangeStart, long rangeEnd, Handle hText, StScrpHandle hStyles, WESoupHandle hSoup, WEReference we);
  638.  
  639. /*    getting and setting the alignment style */
  640.  
  641. pascal WEAlignment WEGetAlignment(WEReference we);
  642. pascal void WESetAlignment(WEAlignment alignment, WEReference we);
  643.  
  644. /*    recalculating line breaks, drawing and scrolling */
  645.  
  646. pascal OSErr WECalText(WEReference we);
  647. pascal void WEUpdate(RgnHandle updateRgn, WEReference we);
  648. pascal void WEScroll(long hOffset, long vOffset, WEReference we);
  649. pascal void WESelView(WEReference we);
  650.  
  651. /*    handling activate / deactivate events */
  652.  
  653. pascal void WEActivate(WEReference we);
  654. pascal void WEDeactivate(WEReference we);
  655.  
  656. /*     handling key-down events */
  657.  
  658. pascal void WEKey(short key, EventModifiers modifiers, WEReference we);
  659.  
  660. /*    handling mouse-down events and mouse tracking */
  661.  
  662. pascal void WEClick(Point hitPt, EventModifiers modifiers, unsigned long clickTime, WEReference we);
  663.  
  664. /*    adjusting the cursor shape */
  665.  
  666. pascal Boolean WEAdjustCursor(Point mouseLoc, RgnHandle mouseRgn, WEReference we);
  667.  
  668. /*    blinking the caret */
  669.  
  670. pascal void WEIdle(unsigned long *maxSleep, WEReference we);
  671.  
  672. /*    modifying the text and the styles */
  673.  
  674. pascal OSErr WEInsert(const void *pText, long textLength, StScrpHandle hStyles, WESoupHandle hSoup, WEReference we);
  675. pascal OSErr WEDelete(WEReference we);
  676. pascal OSErr WESetStyle(WEStyleMode mode, const TextStyle *ts, WEReference we);
  677. pascal OSErr WEUseStyleScrap(StScrpHandle hStyles, WEReference we);
  678. pascal OSErr WEUseText(Handle hText, WEReference we);
  679.  
  680. /*    undo */
  681.  
  682. pascal OSErr WEUndo(WEReference we);
  683. pascal void WEClearUndo(WEReference we);
  684. pascal WEActionKind WEGetUndoInfo(Boolean *redoFlag, WEReference we);
  685. pascal Boolean WEIsTyping(WEReference we);
  686.  
  687. /*    keeping track of changes */
  688.  
  689. pascal unsigned long WEGetModCount(WEReference we);
  690. pascal void WEResetModCount(WEReference we);
  691.  
  692. /*    embedded objects */
  693.  
  694. pascal OSErr WEInstallObjectHandler(FlavorType objectType, WESelector handlerSelector, UniversalProcPtr handler, WEReference we);
  695. pascal OSErr WEInsertObject(FlavorType objectType, Handle objectDataHandle, Point objectSize, WEReference we);
  696. pascal OSErr WEGetSelectedObject(WEObjectReference *obj, WEReference we);
  697. pascal long WEFindNextObject(long offset, WEObjectReference *obj, WEReference we);
  698. pascal OSErr WEUseSoup(WESoupHandle hSoup, WEReference we);
  699.  
  700. /*    accessing embedded object attributes */
  701.  
  702. pascal FlavorType WEGetObjectType(WEObjectReference obj);
  703. pascal Handle WEGetObjectDataHandle(WEObjectReference obj);
  704. pascal Point WEGetObjectSize(WEObjectReference obj);
  705. pascal WEReference WEGetObjectOwner(WEObjectReference obj);
  706. pascal long WEGetObjectRefCon(WEObjectReference obj);
  707. pascal void WESetObjectRefCon(WEObjectReference obj, long refCon);
  708.  
  709. /*    clipboard operations */
  710.  
  711. pascal OSErr WECut(WEReference we);
  712. pascal OSErr WECopy(WEReference we);
  713. pascal OSErr WEPaste(WEReference we);
  714. pascal Boolean WECanPaste(WEReference we);
  715.  
  716. /*    Drag Manager support */
  717.  
  718. pascal RgnHandle WEGetHiliteRgn(long rangeStart, long rangeEnd, WEReference we);
  719. pascal OSErr WETrackDrag(DragTrackingMessage message, DragReference drag, WEReference we);
  720. pascal OSErr WEReceiveDrag(DragReference drag, WEReference we);
  721. pascal Boolean WECanAcceptDrag(DragReference drag, WEReference we);
  722. pascal Boolean WEDraggedToTrash(DragReference drag);
  723.  
  724. /*    Script Manager utilities */
  725.  
  726. pascal short WECharByte(long offset, WEReference we);
  727. pascal short WECharType(long offset, WEReference we);
  728.  
  729. /*    Text Services Manager support */
  730.  
  731. pascal OSErr WEInstallTSMHandlers(void);
  732. pascal OSErr WERemoveTSMHandlers(void);
  733. pascal void WEStopInlineSession(WEReference we);
  734.  
  735. /*    additional features */
  736.  
  737. pascal short WEFeatureFlag(short feature, short action, WEReference we);
  738. pascal OSErr WEGetInfo(WESelector selector, void *info, WEReference we);
  739. pascal OSErr WESetInfo(WESelector selector, const void *info, WEReference we);
  740.  
  741. /*    long coordinate utilities */
  742.  
  743. pascal void WELongPointToPoint(const LongPt *lp, Point *p);
  744. pascal void WEPointToLongPoint(Point p, LongPt *lp);
  745. pascal void WESetLongRect(LongRect *lr, long left, long top, long right, long bottom);
  746. pascal void WELongRectToRect(const LongRect *lr, Rect *r);
  747. pascal void WERectToLongRect(const Rect *r, LongRect *lr);
  748. pascal void WEOffsetLongRect(LongRect *lr, long hOffset, long vOffset);
  749. pascal Boolean WELongPointInLongRect(const LongPt *lp, const LongRect *lr);
  750.  
  751. #ifdef __cplusplus
  752. }
  753. #endif
  754.  
  755. #if defined(powerc) || defined (__powerc)
  756. #pragma options align=reset
  757. #endif
  758.  
  759. #endif
  760.